package service.impl;

import dao.ResumeDao;
import domain.Recruiter;
import domain.Resume;
import service.ResumeService;
import util.MyBatisUtil;

import java.util.List;

public final class ResumeServiceImpl implements ResumeService {
    private ResumeServiceImpl() {}
    private static final ResumeServiceImpl INSTANCE = new ResumeServiceImpl();
    private static final ResumeDao resumeDao = MyBatisUtil.getMapper(ResumeDao.class);
    public static ResumeServiceImpl getINSTANCE() { return INSTANCE; }

    @Override
    public int addResume(Resume resume) {
        return resumeDao.insert(resume);
    }

    @Override
    public int resetResume(Resume resume) {
        return resumeDao.update(resume);
    }

    @Override
    public Resume selectById(Long id) {
        return resumeDao.selectById(id);
    }

    @Override
    public List<Resume> selectByRecruiterId(Long recruiterId) {
        return resumeDao.selectByRecruiterId(recruiterId);
    }

    @Override
    public List<Resume> selectByJobholderId(Long jobholderId) {
        return resumeDao.selectByJobholderId(jobholderId);
    }

    @Override
    public List<Resume> selectByJobholderIdAndPassState(Long jobholderId, int passState) {
        return resumeDao.selectByJobholderIdAndPassState(jobholderId, passState);
    }

    @Override
    public List<Resume> selectAll() {
        return resumeDao.selectAll();
    }

    @Override
    public int onResume(Resume resume) {
        resume.setPassState(1);
        return resumeDao.update(resume);
    }
}
